/**
 *    Copyright (c) [2021] [白晓明]
 *    [IMHarmonyOSLib] is licensed under Mulan PSL v2.
 *    You can use this software according to the terms and conditions of the Mulan PSL v2.
 *    You may obtain a copy of Mulan PSL v2 at:
 *             http://license.coscl.org.cn/MulanPSL2
 *    THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *    See the Mulan PSL v2 for more details.
 */
package com.itming.ui.sample.slice;

import com.itming.ui.coptlib.core.IMIconButton;
import com.itming.ui.sample.ResourceTable;
import com.itming.ui.uilib.bar.IMCustomTitleBar;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.window.service.WindowManager;

public class UiLibTitleAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_ui_lib_title);
//        getWindow().addFlags(WindowManager.LayoutConfig.MARK_FULL_SCREEN);

//        Component componentById = findComponentById(ResourceTable.Id_custom_title);
        IMIconButton leftBtn = (IMIconButton) findComponentById(ResourceTable.Id_back_btn);
        leftBtn.setClickedListener(l -> {
            super.onBackPressed();
        });

        IMCustomTitleBar titleBar = (IMCustomTitleBar) findComponentById(ResourceTable.Id_custom_title_bar);
        IMIconButton backBtn = (IMIconButton) titleBar.findComponentById(com.itming.ui.uilib.ResourceTable.Id_back_btn);
        backBtn.setClickedListener(l -> {
            super.onBackPressed();
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
